//
//  BPUISearchToolView.m
//  AFNetworking
//
//  Created by 404 on 2020/7/31.
//

#import "BPUISearchToolView.h"

@implementation BPUISearchToolView

- (void)didInitialize{
    [super didInitialize];
    _searchBackgroundView = [[UIView alloc] init];
    _searchBackgroundView.layer.cornerRadius = 16;
    _searchBackgroundView.layer.masksToBounds = YES;
    _searchBackgroundView.backgroundColor = UIColorMake(241, 241, 241);
    [self.backgroundView addSubview:_searchBackgroundView];
    
    _searchIconView = [[UIImageView alloc] initWithImage:
                       UIImageMake(@"nav_search.png")];
    [self.searchBackgroundView addSubview:_searchIconView];
    
    _searchTextField = [[UITextField alloc] init];
    _searchTextField.font = UIFontMake(16);
    _searchTextField.placeholder = @"搜索";
    [self.searchBackgroundView addSubview:_searchTextField];
    
    self.rightButton.hidden = NO;
    [self.rightButton setTitle:@"搜索" forState:UIControlStateNormal];
    self.rightButton.titleLabel.font = UIFontMake(18);
    [self.rightButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.rightButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}

- (void)layoutSubviews {
    self.searchBackgroundView.frame = CGRectMake(50, 6, self.backgroundView.width - 50 - 60, 32);
    
    self.searchIconView.frame = CGRectMake(8, 8, 15, 15);
    self.searchTextField.frame = CGRectMake(CGRectGetMaxX(self.searchIconView.frame) + 8, 0, self.searchBackgroundView.width - self.searchIconView.right - 8 - 10, self.searchBackgroundView.height);
    self.rightButton.frame = CGRectMake(SCREEN_WIDTH-50, 0, 45, 44);
}
@end
